from apscheduler.schedulers.blocking import BlockingScheduler
import datetime
from apscheduler.jobstores.memory import MemoryJobStore
from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor
from main_time import main
from notify.send_feishu_debug import send_test_report


def my_job_1(id='my_job_1'):
    print(id, '-->', datetime.datetime.now())
    main()

def my_job_2(id='my_job_2'):
    print(id, '-->', datetime.datetime.now())
    send_test_report()


jobstores = {'default': MemoryJobStore()}

executors = {'default': ThreadPoolExecutor(20), 'processpool': ProcessPoolExecutor(10)}

job_defaults = {'coalesce': False, 'max_instances': 3}

scheduler = BlockingScheduler(jobstores=jobstores, executors=executors, job_defaults=job_defaults)

scheduler.add_job(my_job_1, args=['job_cron_1', ], id='job_cron_1', trigger='cron', day_of_week='0-6', hour=11, minute=13)
scheduler.add_job(my_job_2, args=['job_cron_2', ], id='job_cron_2', trigger='cron', day_of_week='0-6', hour=11, minute=14)

try:
    scheduler.start()
except SystemExit:
    print('exit')
    exit()



# 本地定时任务推送